package org.example.thread;

import java.util.concurrent.atomic.AtomicReference;

public class AtomicReferenceDemo {
    public static void main(String[] args) {
        User zhangsan=new User("zhangsan",19);
        User liSi = new User("lisi",20);

        AtomicReference<User> atomicReference=new AtomicReference<>();
        atomicReference.set(zhangsan);

        System.out.println(atomicReference.compareAndSet(zhangsan, liSi)+"\t"+atomicReference.get().toString());

        System.out.println(atomicReference.compareAndSet(zhangsan, liSi)+"\t"+atomicReference.get().toString());
    }


    public void test2(){
        new Thread(() -> System.out.println("do something..")).start();
    }

}
